<!DOCTYPE html
          PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html   xmlns   = "http://www.w3.org/1999/xhtml">
<head>
<link rel="STYLESHEET" href="filtersdk.css" type="text/css" />
<title>EnvSaveString - AviSynth</title>
</head>
<BODY>

<div id="body">

<h1><a href="http://www.avisynth.org/EnvSaveString" style="text-decoration:none">
    EnvSaveString</a>
    	<p>
	</h1>

<p><strong>env->SaveString</strong> is given to allow users to pass strings to AVSValue, 
and ensure that they are being deallocated on unload.</p>


<p>An Example:</p>

<pre>      fnpluginnew = new char[string_len];

      strcpy(fnpluginnew, fnplugin.AsString());
      strcat(fnpluginnew, " ");
      strcat(fnpluginnew, name);
      
      env->SetGlobalVar("$PluginFunctions$", AVSValue(env->SaveString(fnpluginnew, string_len)));

      // Since fnpluginnew has now been saved it can safely be deleted.

      delete[] fnpluginnew;
</pre>

<p>But you must still remember that these strings are not deallocated until the filter is unloaded.</p>

<p>So in general if you don't want your filter to be allocating more memory on each load, 
try avoiding using non-const strings.</p>


<h3>Back to <a href="InternalFunctions.htm">InternalFunctions</a></h3></div>
<p><kbd>$Date: 2006/11/24 18:21:26 $<br>
Original version of this document <a href="http://www.avisynth.org/EnvSaveString">http://www.avisynth.org/EnvSaveString</a>
</kbd></p>
</BODY>
</html>
